package com.ruoyi.management_controller.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.management_controller.RepresentingAppearance.domain.RepresentingAppearance;
import com.ruoyi.management_controller.RepresentingAppearance.service.IRepresentingAppearanceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 代表风采Controller
 *
 * @author ruoyi
 * @date 2024-07-07
 */
@RestController
@RequestMapping("/RepresentingAppearance/RepresentingAppearance")
public class RepresentingAppearanceController extends BaseController
{
    @Autowired
    private IRepresentingAppearanceService representingAppearanceService;

    /**
     * 查询代表风采列表
     */
   @PreAuthorize("@ss.hasPermi('RepresentingAppearance:RepresentingAppearance:list')")
    @GetMapping("/list")
    public TableDataInfo list(RepresentingAppearance representingAppearance)
    {
        startPage();
        List<RepresentingAppearance> list = representingAppearanceService.selectRepresentingAppearanceList(representingAppearance);
        return getDataTable(list);
    }

    /**
     * 导出代表风采列表
     */
    @PreAuthorize("@ss.hasPermi('RepresentingAppearance:RepresentingAppearance:export')")
    @Log(title = "代表风采", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RepresentingAppearance representingAppearance)
    {
        List<RepresentingAppearance> list = representingAppearanceService.selectRepresentingAppearanceList(representingAppearance);
        ExcelUtil<RepresentingAppearance> util = new ExcelUtil<RepresentingAppearance>(RepresentingAppearance.class);
        util.exportExcel(response, list, "代表风采数据");
    }

    /**
     * 获取代表风采详细信息
     */
    @PreAuthorize("@ss.hasPermi('RepresentingAppearance:RepresentingAppearance:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(representingAppearanceService.selectRepresentingAppearanceById(id));
    }

    /**
     * 新增代表风采
     */
    @PreAuthorize("@ss.hasPermi('RepresentingAppearance:RepresentingAppearance:add')")
    @Log(title = "代表风采", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RepresentingAppearance representingAppearance)
    {
        representingAppearance.setId(RepresentingAppearance.getDefaultId());
        return toAjax(representingAppearanceService.insertRepresentingAppearance(representingAppearance));
    }

    /**
     * 修改代表风采
     */
    @PreAuthorize("@ss.hasPermi('RepresentingAppearance:RepresentingAppearance:edit')")
    @Log(title = "代表风采", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RepresentingAppearance representingAppearance)
    {
        return toAjax(representingAppearanceService.updateRepresentingAppearance(representingAppearance));
    }

    /**
     * 删除代表风采
     */
    @PreAuthorize("@ss.hasPermi('RepresentingAppearance:RepresentingAppearance:remove')")
    @Log(title = "代表风采", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(representingAppearanceService.deleteRepresentingAppearanceByIds(ids));
    }
}
